package com.huanying.goodjob.message;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.huanying.framework.user.User;
import com.huanying.goodjob.job.Jobitem;

@Entity
@Table(name="message")
public class Message {
	private static final long serialVersionUID = -8714406550574846572L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id; //id
	 @OneToOne(cascade = { CascadeType.ALL })
	@JoinColumn(name = "senduser_id")
    private User sender ; //发消息人
	 @ManyToOne(cascade = CascadeType.REFRESH, optional = false, fetch = FetchType.LAZY)
	 @NotFound(action = NotFoundAction.IGNORE)
	 @JoinColumn(name = "jobitem_id")
    private Jobitem jobitem;  //工作项
    @OneToOne(cascade = { CascadeType.ALL })
	@JoinColumn(name = "reciveuser_id")
    private User receiver ;  //接收人
    private String message;   //消息内容
    private int receiver_type;  //接收人类别 0工人 1工长
    @Column(name = "issystemmessage", columnDefinition = "INT default 1")
    private int issystemmessage; //是否是系统消息
  
	 @Column(name = "checkstatus",columnDefinition = "INT default 0")
	private int checkstatus;  //是否查看 0未查看  1已查看
    @Column(name = "status", nullable = false, columnDefinition = "INT default 1")
	private int status;
	public int getReceiver_type() {
		return receiver_type;
	}
	public void setReceiver_type(int receiver_type) {
		this.receiver_type = receiver_type;
	}
	public int getIssystemmessage() {
  		return issystemmessage;
  	}
  	public void setIssystemmessage(int issystemmessage) {
  		this.issystemmessage = issystemmessage;
  	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	public User getSender() {
		return sender;
	}
	public void setSender(User sender) {
		this.sender = sender;
	}
	public User getReceiver() {
		return receiver;
	}
	public void setReceiver(User receiver) {
		this.receiver = receiver;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public int getCheckstatus() {
		return checkstatus;
	}
	public void setCheckstatus(int checkstatus) {
		this.checkstatus = checkstatus;
	}
	public Jobitem getJobitem() {
		return jobitem;
	}
	public void setJobitem(Jobitem jobitem) {
		this.jobitem = jobitem;
	} 
}
